package game.Config;


import java.util.ArrayList;
import java.util.HashMap;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import Weapons.Flamethrower;
import Weapons.FreezeGun;
import Weapons.MachineGun;
import Weapons.MineGun;
import Weapons.Pistol;
import Weapons.RicochetGun;
import Weapons.RocketGun;
import Weapons.ScatterGun;
import Weapons.Shotgun;
import Weapons.Weapon;

/**
 * This class contains bullet configurations for the game.
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class Weaponry {
	public static HashMap<Weapon, Image> weaponImageTable = new HashMap<Weapon, Image>();
	public static ArrayList<Weapon> weapons = new ArrayList<Weapon>();
	
	public static Pistol pistol;
	private static Image pistolImage;
	private static final float PISTOL_FIRERATE = 2;
	private static final float PISTOL_DAMAGE = 1;
	private static final float PISTOL_BULLET_SPEED = 400f;
	
	public static MachineGun machineGun;
	private static Image machineGunImage;
	private static final float MACHINEGUN_FIRERATE = 10;
	private static final float MACHINEGUN_DAMAGE = 0.33f;
	private static final float MACHINEGUN_BULLET_SPEED = 400f;
	private static final double MACHINEGUN_SPREAD = 30f;
	
	public static Shotgun shotgun;
	private static Image shotgunImage;
	private static final float SHOTGUN_FIRERATE = 1;
	private static final float SHOTGUN_DAMAGE = 0.5f;
	private static final float SHOTGUN_BULLET_SPEED = 400f;
	private static final float SHOTGUN_NUMBER_BULLETS = 3;
	private static final double SHOTGUN_SPREAD = 45;
	private static final float SHOTGUN_FADE_DISTANCE = 115f;
	
	public static FreezeGun freezeGun;
	private static Image freezeGunImage;
	private static final float FREEZEGUN_FIRERATE = 3;
	private static final float FREEZEGUN_DAMAGE = 0;
	private static final float FREEZEGUN_BULLET_SPEED = 400f;
	private static final float FREEZEGUN_NUMBER_BULLETS = 5f;
	private static final float FREEZEGUN_FADE_DISTANCE = 75f;
	private static final float FREEZEGUN_FREEZE_DURATION = 4f;
	private static final float FREEZEGUN_FREEZE_PERCENT = 0.3f;
	
	public static RocketGun rocketGun;
	private static Image rocketGunImage;
	private static final float ROCKETGUN_FIRERATE = 0.5f;
	private static final float ROCKETGUN_DAMAGE = 3;
	private static final float ROCKETGUN_BULLET_SPEED = 300f;
	private static final float ROCKETGUN_EXPLOSION_RADIUS = 150f;
	
	public static ScatterGun scatterGun;
	private static Image scatterGunImage;
	private static final float SCATTERGUN_FIRERATE = 2f;
	private static final float SCATTERGUN_DAMAGE = 0.1f;
	private static final float SCATTERGUN_BULLET_SPEED = 400f;
	private static final float SCATTERGUN_NUMBER_BULLETS = 20;
	private static final float SCATTERGUN_FADE_DISTANCE = 75f;
	
	public static MineGun mineGun;
	private static Image mineGunImage;
	private static final float MINEGUN_FIRERATE = 0.5f;
	private static final float MINEGUN_DAMAGE = 1f;
	private static final float MINEGUN_EXPLOSION_RADIUS = 64f;
	
	public static Flamethrower flamethrower;
	private static Image flamethrowerImage;
	private static final float FLAMETHROWER_FIRERATE = 100f;
	private static final float FLAMETHROWER_DAMAGE = 0.01f;
	private static final float FLAMETHROWER_BULLET_SPEED = 100f;
	private static final float FLAMETHROWER_RECOIL = 30f;
	private static final float FLAMETHROWER_FADE_DISTANCE = 50f;
	private static final float FLAMETHROWER_BURN_DURATION = 1f;
	private static final float FLAMETHROWER_BURN_DAMAGE = 0.1f;
	
	public static RicochetGun ricochetGun;
	private static Image ricochetGunImage;
	private static final float RICOCHETGUN_FIRERATE = 1;
	private static final float RICOCHETGUN_DAMAGE = 0.5f;
	private static final float RICOCHETGUN_BULLET_SPEED = 400f;
	private static final float RICOCHETGUN_BOUNCE_RADIUS = 100f;
	private static final int RICOCHETGUN_MAXIMUM_BOUNCES = 4;

	/**
	 * Initializes the different bullet configurations and associated images.
	 * @throws SlickException
	 */
	public static void initialize() throws SlickException{
		pistol = new Pistol(PISTOL_FIRERATE,PISTOL_DAMAGE,PISTOL_BULLET_SPEED);
		machineGun = new MachineGun(MACHINEGUN_FIRERATE,MACHINEGUN_DAMAGE,MACHINEGUN_BULLET_SPEED,MACHINEGUN_SPREAD);
		shotgun = new Shotgun(SHOTGUN_FIRERATE,SHOTGUN_DAMAGE,SHOTGUN_BULLET_SPEED,SHOTGUN_NUMBER_BULLETS,SHOTGUN_SPREAD,SHOTGUN_FADE_DISTANCE);
		freezeGun = new FreezeGun(FREEZEGUN_FIRERATE,FREEZEGUN_DAMAGE,FREEZEGUN_BULLET_SPEED,FREEZEGUN_NUMBER_BULLETS,FREEZEGUN_FADE_DISTANCE,FREEZEGUN_FREEZE_DURATION,FREEZEGUN_FREEZE_PERCENT);
		rocketGun = new RocketGun(ROCKETGUN_FIRERATE,ROCKETGUN_DAMAGE,ROCKETGUN_BULLET_SPEED,ROCKETGUN_EXPLOSION_RADIUS);
		scatterGun = new ScatterGun(SCATTERGUN_FIRERATE,SCATTERGUN_DAMAGE,SCATTERGUN_BULLET_SPEED,SCATTERGUN_NUMBER_BULLETS,SCATTERGUN_FADE_DISTANCE);
		mineGun = new MineGun(MINEGUN_FIRERATE,MINEGUN_DAMAGE,MINEGUN_EXPLOSION_RADIUS);
		flamethrower = new Flamethrower(FLAMETHROWER_FIRERATE,FLAMETHROWER_DAMAGE,FLAMETHROWER_BULLET_SPEED,FLAMETHROWER_RECOIL,FLAMETHROWER_FADE_DISTANCE,FLAMETHROWER_BURN_DURATION,FLAMETHROWER_BURN_DAMAGE);
		ricochetGun = new RicochetGun(RICOCHETGUN_FIRERATE,RICOCHETGUN_DAMAGE,RICOCHETGUN_BULLET_SPEED,RICOCHETGUN_BOUNCE_RADIUS,RICOCHETGUN_MAXIMUM_BOUNCES);
		weapons.add(pistol);
		weapons.add(machineGun);
		weapons.add(shotgun);
		weapons.add(freezeGun);
		weapons.add(rocketGun);
		weapons.add(scatterGun);
		weapons.add(mineGun);
		weapons.add(flamethrower);
		weapons.add(ricochetGun);
		
		loadImages();
		mapImages();
	}
	
	private static void loadImages() throws SlickException {
		pistolImage = new Image("PistolHudImage.png");
		machineGunImage = new Image("MachineGunHudImage.png");
		shotgunImage = new Image("ShotGunHudImage.png");
		freezeGunImage = new Image("FreezeGunHudImage.png");
		rocketGunImage = new Image("RocketGunHudImage.png");
		scatterGunImage = new Image("ScatterGunHudImage.png");
		mineGunImage = new Image("MineGunHudImage.png");
		flamethrowerImage = new Image("FlameThrowerHudImage.png");
		ricochetGunImage = new Image("PistolHudImage.png");
	}
	
	private static void mapImages() {
		weaponImageTable.put(pistol, pistolImage);
		weaponImageTable.put(machineGun, machineGunImage);
		weaponImageTable.put(shotgun, shotgunImage);
		weaponImageTable.put(freezeGun, freezeGunImage);
		weaponImageTable.put(rocketGun, rocketGunImage);
		weaponImageTable.put(scatterGun, scatterGunImage);
		weaponImageTable.put(mineGun, mineGunImage);
		weaponImageTable.put(flamethrower, flamethrowerImage);
		weaponImageTable.put(ricochetGun, ricochetGunImage);
	}
}
